package utils.db.helper.impl;

import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;

public class QueryDetailer {
	private ResultSetMetaData md;
	private Object[][] records;
	private int col = 0, now = 0, row = 0;
	private ResultSet rs;

	public ResultSet getRs() {
		return rs;
	}

	public void setRs(ResultSet rs) {
		this.rs = rs;
	}

	public QueryDetailer(ResultSet rs) throws SQLException {
		this.md = rs.getMetaData();
		this.col = md.getColumnCount();
		while (rs.next()) {
			now = rs.getRow();
			if (now > row) {
				this.row = now;
			}
		}
		records = new Object[this.row][this.col];
		rs.beforeFirst();
	}

	public static boolean castToBool(int i) {
		if (i == 1) {
			return true;
		} else
			return false;
	}

	public ResultSetMetaData getMd() {
		return md;
	}

	public void setMd(ResultSetMetaData md) {
		this.md = md;
	}

	public Object[][] getRecords() {
		return records;
	}

	public void setRecords(Object[][] records) {
		this.records = records;
	}

	public int getCol() {
		return col;
	}

	public void setCol(int col) {
		this.col = col;
	}

	public int getNow() {
		return now;
	}

	public void setNow(int now) {
		this.now = now;
	}

	public int getRow() {
		return row;
	}

	public void setRow(int row) {
		this.row = row;
	}

}
